#ifndef __DS_MODELS__
#define __DS_MODELS__

#include <string.h>
#include <map>

#include <boost/shared_ptr.hpp>

namespace ds {

class Models {
private:
    static std::map<std::string, boost::shared_ptr<egl::video::Model> > models;

public:
    /// Get specified model.
    inline static boost::shared_ptr<egl::video::Model> get(const std::string &name) {
        std::map<std::string, boost::shared_ptr<egl::video::Model> >::iterator iter = models.find(name);
        if (iter != models.end())
            return iter->second;
        return boost::shared_ptr<egl::video::Model>();
    }

    /// Returns true if the specified model exists.
    inline static bool has(const std::string &name) {
        std::map<std::string, boost::shared_ptr<egl::video::Model> >::iterator iter = models.find(name);
        if (iter != models.end())
            return true;
        return false;
    }

    /// Replace model.
    inline static void set(const std::string &name, boost::shared_ptr<egl::video::Model> model) {
        models.insert(std::pair<std::string, boost::shared_ptr<egl::video::Model> >(name, model));
    }

    /// Adds a model only if it isn't already added.
    inline static void add(const std::string &name, boost::shared_ptr<egl::video::Model> model) {
        std::map<std::string, boost::shared_ptr<egl::video::Model> >::iterator iter = models.find(name);
        if (iter == models.end())
            models.insert(std::pair<std::string, boost::shared_ptr<egl::video::Model> >(name, model));
    }

    /// Removes all models.
    inline static void clear() {
        models.clear();
    }
};

std::map<std::string, boost::shared_ptr<egl::video::Model> > Models::models;

} // namespace ds

#endif
